<script>
    function submitForm() {
        document.getElementById("formularioBusca").submit();
    }
</script>

<?php
    
    if (isset($_GET['empresa'])) {
        $empresa = $_GET['empresa'];
    } else {
        $empresa = "";
    }
?>

<form name="formularioBusca" id="formularioBusca" method="get" action="">
    <div style="float: left" >
        <label>
            <select name="empresa" id="empresa"  style="width: 340px" >
                <option  value="">Empresas</option>
                    <?php
                    $objempresas = new Pessoas_Model();
                    $empr = $objempresas->getDadosEmpresasGruposUsuario();

                    foreach ($empr as $e) { ?>
                        <option <?php
                                    if ($empresa == $e->pessoas_id) {
                                        echo "selected='selected'";
                                    }
                                    ?> value="<?php echo $e->pessoas_id ?>"><?php echo $e->pessoas_razaoSocial ?></option>
                    
                <?php } ?>
            </select>
        </label>                   
    </div>
    <div style="float: left; vertical-align: middle">        
        <a class="medium" style="color: #000; font-size: 35px; padding-right: 10px; margin-left: 10px;" target="_blank" title="Filtrar" onclick="submitForm()">
            <i class="fi-magnifying-glass big"></i>
        </a>        
    </div> 
</form>
<br />
<br />
<br />
<br />
    
<table width="100%"  class="table table-bordered table-hover" border="1px" cellspacing="0" cellpadding="0">
    <thead>

        <tr>
            <td bgcolor="#fff" width="30%"><center>Empresa</center></td>
<td bgcolor="#fff" width="20%"><center>Esfera</center></td>
<td bgcolor="#fff" width="40%"><center>Descrição da Pendência</center></td>
<td bgcolor="#fff" width="10%"><center>Valor</center></td>
</tr>
</thead>
<?php
$cont = 0;
foreach ($pendencias as $pendencia) {
    $cont++;
    ?>

    <tr>
        <td><?php echo $pendencia->pessoas_razaoSocial ?></td>
        <td>
    <?php echo $pendencia->tipoCnd_descricao ?>
        </td>

        <td>
    <?php echo $pendencia->pendencias_descricao ?>
        </td>
        <td align="left">
            R$ <?php echo number_format($pendencia->pendencias_valor, 2, ',', '.') ?>
        </td>

    </tr> 
    <?php
}
?> 
<tr>
    <td colspan="4">
        <b>Total de pendências:</b> <?php echo $cont; ?>
    </td>
</tr>

</table>